<!--分享页面-->
<template>
  <div>
    <!-- 返回上一页图标 -->
    <van-icon
      class="to-back"
      size="40"
      color="#EFEFEF"
      @click="toBack"
      name="arrow-left"
    />
    <!-- 分享图标 -->
    <van-icon
      class="share"
      size="40"
      color="#EFEFEF"
      @click="showShare = true"
      name="share-o"
    />
    <!-- 分享面板 -->
    <van-share-sheet
      v-model="showShare"
      title="立即分享给好友"
      :options="options"
      @select="onSelect"
    />
  </div>
</template>

<script>
export default {
  data() {
    return {
      showShare: false,
      options: [
        { name: "微信", icon: "wechat" },
        { name: "微博", icon: "weibo" },
        { name: "复制链接", icon: "link" },
        { name: "分享海报", icon: "poster" },
        { name: "二维码", icon: "qrcode" },
      ],
    };
  },
  methods: {
    toBack() {
      // 返回上一页
      this.$router.back(-1);
    },
    onSelect(option) {
      // console.log(22, option, index);
      this.$toast(option.name);
      //隐藏分享面板
      this.showShare = false;
    },
  },
};
</script>

<style lang="less" scode>
.to-back {
  position: fixed;
  top: 0.2rem;
  left: 0.1rem;
  z-index: 999;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 50%;
}
.share {
  position: fixed;
  top: 0.2rem;
  right: 0.1rem;
  z-index: 999;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 50%;
}
</style>